const {Sequelize} = require("sequelize");
const {createPool} = require("mysql2");
const sequelize = new Sequelize('webtest', 'root', 'root', {
        host: 'localhost',
        dialect: 'mysql',/* 选择 'mysql' | 'mariadb' | 'postgres' | 'mssql' 其一 */
        logging: (...msg) => console.log(msg), /*开启日志*/
        //修改默认数据库连接池
        pool: {
            max: 10,
            min: 2,
            //空闲连接超时时间
            idle: 30000,
            //获取连接的最大等待时间
            acquire: 20000,
            //释放连接后 10s后自动回收
            evict: 10000,
            //保证连接有效 在空闲超时后 自动调用该函数
            validate: (conn) => {
                return conn.query('SELECT 1+1');
            }
        }
    },


);
module.exports = {sequelize}